import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';
import { GENDER } from '@/enum/user';
import { RECORD_STATUS } from '@/enum/common';
import { BaseEntity } from './base.entity';

@Entity('users')
export class User extends BaseEntity {
  @PrimaryGeneratedColumn({
    type: 'int',
    name: 'id',
    comment: '主键,自增',
  })
  id: number;

  @Column({
    name: 'opend_id',
    type: 'varchar',
    length: 255,
    comment: '用户的openId',
    default: '',
  })
  opendId: string;

  @Column({
    name: 'nick_name',
    type: 'varchar',
    length: 255,
    comment: '用户昵称',
    default: '',
  })
  nickName: string;

  @Column({
    name: 'gender',
    type: 'int',
    comment: '性别，男1，女2，未知3',
    default: GENDER.UNKNONW,
  })
  gender: GENDER;

  @Column({
    name: 'avatar_url',
    type: 'text',
    comment: '用户头像',
    default: null,
  })
  avatarUrl: string;

  @Column({
    name: 'country',
    type: 'varchar',
    comment: '用户所在国家',
    default: null,
  })
  country: string;

  @Column({
    name: 'province',
    type: 'varchar',
    comment: '用户所在省份',
    default: null,
  })
  province: string;

  @Column({
    name: 'city',
    type: 'varchar',
    comment: '用户所在城市',
    default: null,
  })
  city: string;

  @Column({
    name: 'language',
    type: 'varchar',
    comment: '用户使用语言',
    default: null,
  })
  language: string;

  @Column({
    name: 'verification_code',
    type: 'int',
    comment: '验证码',
    default: null,
  })
  verificationCode: string;

  @Column({
    name: 'phone',
    type: 'varchar',
    comment: '手机号',
    nullable: true,
  })
  phone: string;

  @Column({
    name: 'status',
    type: 'int',
    comment: '用户状态，1正常，2隐藏，3禁用',
    default: RECORD_STATUS.SHOW,
  })
  status: RECORD_STATUS;
}
